package cn.itcast.service.impl;

import cn.itcast.dao.ReportSetmealDao;
import cn.itcast.service.ReportSetmealService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ReportSetmealServiceImpl implements ReportSetmealService {

    @Autowired
    private ReportSetmealDao reportSetmealDao;

    @Override
    public Map<String,Object> reportSetmealByCount() {

        HashMap<String, Object> map = new HashMap<>(16);

        List<Map<String, Object>> setmealCount = reportSetmealDao.reportSetmealByCount();
        List<Object> setmealNames = new ArrayList<>();

        for (Map<String, Object> ObjectMap : setmealCount) {
            setmealNames.add(ObjectMap.get("name"));
        }

        map.put("setmealNames",setmealNames);
        map.put("setmealCount",setmealCount);


        return map;
    }
}
